<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>赠课管理</title>
<meta name="renderer" content="webkit">	
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
<meta name="apple-mobile-web-app-status-bar-style" content="black">	
<meta name="apple-mobile-web-app-capable" content="yes">	
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/table.css">
</head>
<body>
	<div class="content-head">悦宝园会员管理系统</div>
	<div class="content-main">
		<div class="side-nav" ms-controller="navBar">
			<ul class="nav-item">
				<li><a href="main.html" class="nav-item-front nav-item-add">首页</a></li>
				<li ms-for="el in @navTitleArr">
					<a href="javascript:;" class="nav-item-front">{{el.par}}</a>
					<dl class="nav-item-child">
						<dd ms-for="($index, ex) in el.child"><a ms-attr='{href: el.href[$index]}'>{{ex}}</a></dd>
					</dl>
				</li>
			</ul>
		</div>
		<div class="content bg-gray"  ms-controller="main">
			<div class="tab-content">
				<div class="tab-item">
					<div class="sub-main">
						<p class="sub-title"><i>增加赠课信息</i></p>
						<div class="import-area">
							<div class="import-block">
								<span class="import-name">宝宝姓名：</span>
								<div class="import-input"><input type="text" maxlength="20" ms-duplex="@name" disabled="disabled"></div>
							</div>
							<div class="import-block">
								<span class="import-name">宝宝小名：</span>
								<div class="import-input"><input type="text" maxlength="20" ms-duplex="@nickName" disabled="disabled"></div>
							</div>
							<div class="import-block">
								<span class="import-name">出生日期：</span>
								<div class="import-input"><input type="date" maxlength="20" ms-duplex="@birthday" disabled="disabled"></div>
							</div>
							<div class="import-block">
								<span class="import-name">赠课：</span>
								<div class="import-input"><input type="text" maxlength="2" style="width:50px;" ms-duplex="@freeClass" id="freeClass">节</div>
							</div>
							<div class="import-block">
								<span class="import-name">原因：</span>
								<div class="import-input"><input type="text" maxlength="100" ms-duplex="@freeClassInfo" id="freeClassInfo"></div>
							</div>
							<div class="import-block">
								<span class="import-name"></span>
								<a href="javascript:;" class="import-btn" ms-on-click="@subForm">增加</a></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<script src="js/jq.js"></script>
<script src="js/avalon.js"></script>
<script src="js/main.js"></script>
<script>
(function() {
	var parName = baseFunc.getSessionData("jumppage");
	var dataObj = baseFunc.getStorageData("member", {flag: parName})[0];
	var obj = {};
	var copyObj = jQuery.extend(true, {}, dataObj);

	function getNowFormatDate() {
		var date = new Date();
		var seperator1 = "-";
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var strDate = date.getDate();
		if (month >= 1 && month <= 9) {
			month = "0" + month;
		}
		if (strDate >= 0 && strDate <= 9) {
			strDate = "0" + strDate;
		}
		var currentdate = year + seperator1 + month + seperator1 + strDate;
		return currentdate;
	}
	
	var vm = avalon.define({
	    $id: "main",
	    name: dataObj.name,
	    nickName: dataObj.nickName,
	    birthday: dataObj.birthday,
	    freeClass: "",
	    freeClassInfo: "",
	    strClass: function(id) {
	    	var status = $("#" + id).attr("data-status"),
	    		that = this;
	    	if(status == "false") {
	    		$("#" + id).removeClass("color-block-gray").addClass("color-block-green");
	    		$("#" + id).attr("data-status", "true");
	    		this.strClassArr.push(id);
	    	} else {
	    		$("#" + id).removeClass("color-block-green").addClass("color-block-gray");
	    		$("#" + id).attr("data-status", "false");
	    		
	    		for(var i = 0; i < that.strClassArr.length; i++) {
	    			if(that.strClassArr[i] == id) {
	    				avalon.Array.removeAt(that.strClassArr,i);
	    			}
	    		}
	    	}
	    	obj.strClass = this.strClassArr;
	    },
	    subForm: function() {
	    	var newObj = {};
	    	newObj["num"] = $.trim(this.freeClass);
	    	newObj["info"] = $.trim(this.freeClassInfo);
	    	newObj["date"] = getNowFormatDate();

	    	if(!dataObj["freeClass"]) {
	    		dataObj["freeClass"] = [];
	    	}
	    	dataObj["freeClass"].push(newObj);
	    	dataObj["classNum"].free = parseInt(dataObj["classNum"].free) + parseInt(newObj["num"]);

    		baseFunc.editStorageData("member", dataObj);
    		baseFunc.locationSkip("freeClass.html");
	    }
	})
})();
</script>
</body>
</html>